package com.chen.springboot.mapper.uniapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.springboot.dto.uniapp.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {
    @Select("SELECT id, name, info, price, picture, discount, order_num AS orderNum FROM goods WHERE category_id = #{categoryId}")
    List<Goods> selectGoodsByCategoryId(String categoryId);

    // 分页查询并模糊搜索商品名
    @Select("SELECT id, name, info, price, picture, discount, order_num AS orderNum " +
            "FROM goods " +
            "WHERE name LIKE CONCAT('%', #{keyword}, '%')")
    Page<Goods> selectPage(Page<Goods> page, @Param("keyword") String keyword);

}